#ifndef COMMON_H
#define COMMON_H

#include <memory>
#include <functional>
#include <random>

#include <stdint.h>

using namespace std;

/*  Опрежедения типов  */
typedef struct _gameConf
{
	int32_t isGameOver;
	int32_t loadtime;
	int32_t turntime;
	int32_t rows;
	int32_t cols;
	int32_t turns;
	int32_t viewradius2;
	int32_t attackradius2;
	int32_t spawnradius2;
	int32_t player_seed;
    char defaultMoves[2];
} GameConf;

typedef struct _coord
{
	int32_t row, column;
} Coord;

typedef enum _cellType
{
    EMPTY = 0,
	ANT = 1,
	WATER = 2,
	ANTHILL = 4,
	FOOD = 8,
} CellType;

class ACell
{
public:
	// переменные
	CellType type;
	Coord coord;

	
	// методы
	ACell(int32_t row, int32_t column)
	{
		this->setCoord(row, column);
	}
	
	ACell(const ACell & aCell)
	{
		this->coord.row = aCell.coord.row;
		this->coord.column = aCell.coord.column;
	}
	
	void setCoord(int32_t xCoord, int32_t yCoord)
	{
		this->coord.row = xCoord;
		this->coord.column = yCoord;
	}
	
	void setCoord(const Coord & c)
	{
		this->coord.row = c.row;
		this->coord.column = c.column;
	}

	Coord & getCoord()
	{
		return this->coord;
	}

	// виртуальные методы метод, описан в унаследованных класса
	virtual bool isEmpty() = 0;
	virtual CellType getType() = 0;
	
	
	int32_t row() const
	{
		return this->coord.row;
	}
	
	int32_t column() const
	{
		return this->coord.column;
	}
};

class ACellCompare
{
public:
	bool operator()(const ACell & ac1, const ACell & ac2) const 
    {
        return (ac1.row() < ac2.row()) ||
                ((ac1.row() == ac2.row()) && (ac1.column() < ac2.column()));
    }
};

class ACellPCompare
{
public:
	bool operator()(const ACell * ac1, const ACell * ac2) const
    {
        return (ac1->row() < ac2->row()) ||
                ((ac1->row() == ac2->row()) && (ac1->column() < ac2->column()));
    }
};

class ACellPtrCompare
{
public:	
	bool operator()(const shared_ptr<ACell> & ac1, const shared_ptr<ACell> & ac2) const
	{
		return (ac1->row() < ac2->row()) ||
                ((ac1->row() == ac2->row()) && (ac1->column() < ac2->column()));
	}
};
#endif /* COMMON_H */
